package com.sk.app;

import android.R.string;
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;

public class ChoseTxc extends Activity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chose_txc);
		final AutoCompleteTextView actv_chose_txc = (AutoCompleteTextView)findViewById(R.id.actv_chose_txc);
		final ListView lv_chose_txc = (ListView)findViewById(R.id.lv_chose_txc);
		ArrayAdapter<String> txcArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.txc_name));
		actv_chose_txc.setAdapter(txcArrayAdapter);
		actv_chose_txc.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				Intent intent = new Intent();
				intent.putExtra("txc_name",((TextView)view).getText());
				ChoseTxc.this.setResult(RESULT_OK,intent);
				finish();
			}			
		});
		lv_chose_txc.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				Intent intent = new Intent();
				intent.putExtra("txc_name",((TextView)view).getText());
				ChoseTxc.this.setResult(RESULT_OK,intent);
				finish();				
			}			
		});
		
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode==KeyEvent.KEYCODE_BACK){
			Intent intent1 = getIntent();
			Intent intent2 = new Intent();
			String txcString = intent1.getExtras().getString("txc_name");
			intent2.putExtra("txc_name", txcString);
			ChoseTxc.this.setResult(RESULT_OK,intent2);
			finish();				
		}
		return super.onKeyDown(keyCode, event);
	}
	


		
		
	
}
